package com.chen.staffjoy.commonlib.validation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;
import java.util.TimeZone;

/**
 * 自定义时区校验器
 * @author Chentian
 * @date 2022/3/16
 */
public class TimezoneValidator implements ConstraintValidator<Timezone, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        if (value == null){
            return true;
        }
        return Arrays.asList(TimeZone.getAvailableIDs()).contains(value);
    }
}
